package com.google.code.nexttraffic.dao.support;

import java.sql.*;

public class SimpleJdbcDaoSupport {

	private final String driver = "oracle.jdbc.driver.OracleDriver";
	private final String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
	private final String id = "soc";
	private final String pw = "soc";
	private Connection conn = null;
	private static SimpleJdbcDaoSupport obj = null;

	public static SimpleJdbcDaoSupport getInstance() {

		if (obj == null) {
			obj = new SimpleJdbcDaoSupport();
		}

		return obj;
	}

	private SimpleJdbcDaoSupport() {

		try {
			Class.forName(driver);
		} catch (Exception e) {
			System.out.println("  헐....");
			e.printStackTrace();
		}
	}

	public Connection getCon() {
		try {
			if (conn == null) {
				conn = DriverManager.getConnection(url, id, pw);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
	}

	public void close() {
		try {
			if (conn != null) {
				conn.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
